# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/25 下午5:07
 @Author  : tgy
 
"""


def test01():
    names = ['zhangsan', 'tony', 'lisi']
    print(','.join(names))
    print('{},{}'.format('123', '2222'))
    # 如果仅仅连接字符串，把字符串放在一起就行了,中间为空格，次数不记
    name_age = 'tony'  '23'
    print(name_age)


def test02():
    a = 10
    b = 20
    c = 30
    # 如果要打印，使用下面的第二种打印
    print(str(a) + ':' + str(b) + ':' + str(c))
    print(a, b, c, sep=':')
    print('==='.join(str_generate()))


def str_generate():
    yield 'hello'
    yield 'world'


def combine(source, max_len=1024):
    ...
    res = []
    cur_len = 0
    for part in source:
        res.append(part)
        cur_len += len(part)
        if cur_len >= max_len:
            yield ''.join(res)
            res = []
            cur_len = 0
    yield ''.join(res)


if __name__ == '__main__':
    ...
    # test02()
    for msg in combine(str_generate(),3):
        print(msg)
    # with open('./a.log', mode='wt', encoding='utf-8') as f:
    #     for msg in combine(str_generate(), 5):
    #         f.write(msg)
